package com.simen.kv;

import android.database.Cursor;

import java.io.Serializable;

/**
 * kv实现类
 * Created by ABC on 2017/4/12.
 */
class KVBlobImpl implements KV<byte[]>, Serializable {
    private long _id;
    private String key;
    private byte[] value;
    private long create;
    private long update;

    public KVBlobImpl(Cursor cursor) {
        this._id = cursor.getLong(cursor.getColumnIndex(Columns._ID));
        this.key = cursor.getString(cursor.getColumnIndex(Columns.KEYNAME));
        this.value = cursor.getBlob(cursor.getColumnIndex(Columns.VALUENAME));
        this.create = cursor.getLong(cursor.getColumnIndex(Columns.CREATETIMENAME));
        this.update = cursor.getLong(cursor.getColumnIndex(Columns.UPDATETIMENAME));
    }

    void setKey(String key) {
        this.key = key;
    }

    void setValue(byte[] value) {
        this.value = value;
    }

    void setCreate(long create) {
        this.create = create;
    }

    void setUpdate(long update) {
        this.update = update;
    }

    @Override
    public long getId() {
        return _id;
    }

    @Override
    public String getKey() {
        return key;
    }

    @Override
    public byte[] getValue() {
        return value;
    }

    @Override
    public long getCreate() {
        return create;
    }

    @Override
    public long getUpdate() {
        return update;
    }
}
